

if [ $# -lt 2 ]; then
 echo "$0 <root directory> <root device>"
 exit 1
fi

sysdir=$1
rootdev=$2

pushd ${sysdir}
ROOTPARTUUID=$(sudo blkid ${rootdev} | awk -F'PARTUUID=' '{ print $2 }')
sudo tee boot/grub/grub.cfg > /dev/null << EOF
menuentry 'My GNU/Linux System for LoongArch64' {
echo 'Loading Linux Kernel ...'
linux /vmlinuz.efi root=PARTUUID=${ROOTPARTUUID} console=ttyS0,115200n8 console=tty0 rootdelay=5 rw panic=30
boot
}
EOF

popd
